package org.robotfish.learn;

import org.ejml.simple.SimpleMatrix;

public abstract class Features {
	String[] featureNames;
	
	public abstract int dimensions();
	
	/**
	 * @param x row/column vector for which features is calculated.
	 * @return
	 */
	public abstract double[] feat(SimpleMatrix x);
	
	/**
	 * @param x
	 * @return calculates features for each row of matrix x
	 */
	public SimpleMatrix featMatrix(SimpleMatrix x) {
		SimpleMatrix f = new SimpleMatrix(x.numRows(), dimensions());
		for (int i=0; i<x.numRows(); i++) {
			double[] vec = feat( x.extractVector(true, i) );
			f.setRow(i, 0, vec);
		}
		return f;
	}
	
	public String[] getFeatureNames() {
		return featureNames;
	}
	
	public void setFeatureNames(String[] featureNames) {
		this.featureNames = featureNames;
	}
	
}
